compiletest/codegen-llvm: automatically add needs-target-std if needed#150672
Closed
xdoardo wants to merge 1 commit intorust-lang:mainfrom
Closed
compiletest/codegen-llvm: automatically add needs-target-std if needed#150672xdoardo wants to merge 1 commit intorust-lang:mainfrom
needs-target-std if needed#150672xdoardo wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
Some changes occurred in src/tools/compiletest cc @jieyouxu |
Collaborator
This comment has been minimized.
This comment has been minimized.
When running the codegen-llvm test suite, the "needs-target-std" directive is automatically added if and only if the "#![no_std]" line is not seen and the "needs-target-std" directive was not already seen. This is a best-effort utility to make running the codegen-llvm test suite for targets that do not support std slightly easier.
aab1410 to
0675c97
Compare
jieyouxu
reviewed
Jan 13, 2026
Member
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Jan 26, 2026
…=Zalathar compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]` A `codegen` mode test (such as `codegen-llvm` test suite) will now by default have an implied `//@ needs-target-std` directive, *unless* the test explicitly has an `#![no_std]`/`#![no_core]` attribute which disables this behavior. - When a test has both `#![no_std]`/`#![no_core]` and `//@ needs-target-std`, the explicit `//@ needs-target-std` directive will cause the test to be ignored for targets that do not support std still. This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual `//@ needs-target-std` busywork. Context: [#t-compiler/help > &rust-lang#96;compiletest&rust-lang#96; cannot find &rust-lang#96;core&rust-lang#96; library for target != host](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60compiletest.60.20cannot.20find.20.60core.60.20library.20for.20target.20!.3D.20host/with/568652419) ## Implementation remarks This is an alternative version of rust-lang#150672, with some differences: - *This* PR applies this implied-`needs-target-std` behavior to all `codegen` test mode tests. - *This* PR does the synthetic directive injection in the same place as implied-`codegen-run` directives. Both are of course hacks, but at least they're together next to each other.
rust-timer
added a commit
that referenced
this pull request
Jan 26, 2026
Rollup merge of #151294 - jieyouxu:infer-needs-target-std, r=Zalathar compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]` A `codegen` mode test (such as `codegen-llvm` test suite) will now by default have an implied `//@ needs-target-std` directive, *unless* the test explicitly has an `#![no_std]`/`#![no_core]` attribute which disables this behavior. - When a test has both `#![no_std]`/`#![no_core]` and `//@ needs-target-std`, the explicit `//@ needs-target-std` directive will cause the test to be ignored for targets that do not support std still. This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual `//@ needs-target-std` busywork. Context: [#t-compiler/help > `compiletest` cannot find `core` library for target != host](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60compiletest.60.20cannot.20find.20.60core.60.20library.20for.20target.20!.3D.20host/with/568652419) ## Implementation remarks This is an alternative version of #150672, with some differences: - *This* PR applies this implied-`needs-target-std` behavior to all `codegen` test mode tests. - *This* PR does the synthetic directive injection in the same place as implied-`codegen-run` directives. Both are of course hacks, but at least they're together next to each other.
Contributor
|
☔ The latest upstream changes (presumably #151667) made this pull request unmergeable. Please resolve the merge conflicts. |
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Jan 26, 2026
compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]` A `codegen` mode test (such as `codegen-llvm` test suite) will now by default have an implied `//@ needs-target-std` directive, *unless* the test explicitly has an `#![no_std]`/`#![no_core]` attribute which disables this behavior. - When a test has both `#![no_std]`/`#![no_core]` and `//@ needs-target-std`, the explicit `//@ needs-target-std` directive will cause the test to be ignored for targets that do not support std still. This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual `//@ needs-target-std` busywork. Context: [#t-compiler/help > `compiletest` cannot find `core` library for target != host](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60compiletest.60.20cannot.20find.20.60core.60.20library.20for.20target.20!.3D.20host/with/568652419) ## Implementation remarks This is an alternative version of rust-lang/rust#150672, with some differences: - *This* PR applies this implied-`needs-target-std` behavior to all `codegen` test mode tests. - *This* PR does the synthetic directive injection in the same place as implied-`codegen-run` directives. Both are of course hacks, but at least they're together next to each other.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running the codegen-llvm test suite, the
needs-target-stddirective is automatically added if and only if the#![no_std]line is not seen and theneeds-target-stddirective was not already seen.This is a best-effort help to make running the codegen-llvm test suite for targets that do not support std slightly easier. Ideally, with time, the tests that aren't marked as no_std but in fact only use types from core/alloc will be patched to reflect this, so that they can be reused for targets without std.
For an explanation of this patch instead of a patch that marks all the tests that aren't
#![no_std]withneeds-target-std, see this Zulip thread. Let me know if, instead, a patch adding theneeds-target-stdis preferred.A simple test of the introduced behaviour is
./x test tests/codegen-llvm/align-fn.rs --target=riscv32e-unknown-none-elf --force-rerun -v. The test does not have theneeds-target-stddirective, but it is ignored with this message: